package com.vehiclemanagement.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vehiclemanagement.entity.Vehicle;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 车辆Mapper接口
 */
@Mapper
public interface VehicleMapper extends BaseMapper<Vehicle> {
    
    /**
     * 检查车牌号是否已存在（排除已删除的）
     * 
     * @param plateNumber 车牌号
     * @return 是否存在
     */
    @Select("SELECT COUNT(*) FROM vehicle WHERE plate_number = #{plateNumber} AND del_flag = 0")
    int existsActiveVehicleWithPlateNumber(@Param("plateNumber") String plateNumber);

    /**
     * 物理删除车辆记录
     * 
     * @param id 车辆ID
     * @return 影响行数
     */
    @Delete("DELETE FROM vehicle WHERE id = #{id}")
    int deletePhysically(@Param("id") Long id);
} 